<%@ page language="java"  pageEncoding="utf-8"%>
<%@taglib uri="/WEB-INF/struts-tags.tld" prefix="s"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>日程查看</title>
<%@include file="../common/jscss.jsp" %>
</head>

<body>
	<!-- head -->
	<%@include file="../common/header.jsp" %>
    <!-- head--end -->
    
    <!-- body -->
    <div class="content">
    	<div class="body_wrap clearfix">
            <div class="com_left" id="schedule_list">
            	<s:if test="scheduleList.list != null && scheduleList.list.size()>0">
            	<div class="com_pd_s1">
                	<div class="box_s2">
                    	<div class="title"><img src="images/other/icon_19.jpg" /><span>日程查看</span></div>
                        <div class="form_list schedule">
                        	<ul class="data_head">
                            	<li class="schedule_time">时间</li><li class="info">内容</li>
                            </ul>
                            <ul class="form_data">
                            	<s:iterator id="schedule" value="scheduleList.list" status="status">
                            		 <li>
	                                    <div class="schedule_time"><img src="images/other/flag_1.jpg" /><span><s:date name="startTime" format="yyyy-MM-dd HH:mm:ss" /></span></div>
	                                    <p class="info"><a href="javascript:;" onclick="showDetail('<s:property value="id"/>')"><s:property value="title"/></a></p>
	                                </li>
                               		
                               	</s:iterator>
                            	
                               
                            </ul>
						</div>
                    </div>
                    
                   <div id="fy_container"></div>
                    
                </div>
                </s:if>
            </div>
            
            <!-- right -->
            <%@include file="right.jsp" %>
            <!--right--end-->
            <br class="clear" />
        </div>
    </div>
           
    <%@include file="../common/footer.jsp" %>
    <script type="text/javascript">
    
    function showDetail(id){
    	$("#schedule_list").load("schedule!read.do?id="+id);
    }
	$(function(){
		
		$.fn.dateBuilder({
			dbID:"mySchedule",
			afterDateBuilder:function(){
				var currentDate=new Date(),currentYear=currentDate.getFullYear(),currentMonth=currentDate.getMonth();
				currentMonth+=1;
				if(currentMonth < 10){
					currentMonth = "0"+currentMonth;
				}
				$.post("schedule!hasdays.do",{
					yearMonth:currentYear+"-"+currentMonth
				},function(data){
					var ret=$.parseJSON(data);
					$.each(ret.days,function(index,item){
						var date=item;
						date = date.substring(8);
						$("#mySchedule").find("td").filter(function(){
								
								if($(this).text()==parseInt(date,10)){
									return true;
								}
							}).wrapInner("<a href='javascript:;' yearMonth='"+currentYear+"-"+currentMonth+"' onclick='showSchList(this)'></a>").addClass("yellow");
						
							
						
					});
					
					if('<s:property value="#session.member.role.scheduleMang" />' == 'true'){
						$("#mySchedule").find("td").filter(function(){
							var aobj = $(this).find("a");
							if(aobj.size() < 1 && $(this).text() != null && $(this).text() != ''){
								return true;
							}
						}).wrapInner("<a href='javascript:;' yearMonth='"+currentYear+"-"+currentMonth+"' onclick='showSchList(this)'></a>");
					}
				});
				
				
			}
		});
		
		var cYear,paraYear;
		var cMonth,paraMonth;
		$("table.dataBuilder").find("span.before").live("click",function(){
			cYear=$("table.dataBuilder").find("i.year").text();
			cMonth=$("table.dataBuilder").find("i.month").text();
			
			if(cMonth==1){
				paraYear=cYear-1;
				paraMonth=11;
			}else{
				paraYear=cYear;
				paraMonth=cMonth-2;
			}
			//alert(paraYear+"--"+paraMonth);
			$.fn.showDate({
				year:paraYear,
				month:paraMonth,
				afterShowDate:function(){
					var currentYear = paraYear;
					var currentMonth = paraMonth;
					currentMonth = parseInt(currentMonth)+1;
					if(currentMonth < 10){
						currentMonth = "0"+currentMonth;
					}
					$.post("schedule!hasdays.do",{
						yearMonth:paraYear+"-"+currentMonth
					},function(data){
						var ret=$.parseJSON(data);
						$.each(ret.days,function(index,item){
							var date=item;
							date = date.substring(8);
							$("#mySchedule").find("td").filter(function(){
								if($(this).text()==parseInt(date,10)){
									return true;
								}
							}).wrapInner("<a href='javascript:;' yearMonth='"+currentYear+"-"+currentMonth+"' onclick='showSchList(this)'></a>").addClass("yellow");
						
							
						});
						
						if('<s:property value="#session.member.role.scheduleMang" />' == 'true'){
							$("#mySchedule").find("td").filter(function(){
								var aobj = $(this).find("a");
								if(aobj.size() < 1 && $(this).text() != null && $(this).text() != ''){
									return true;
								}
							}).wrapInner("<a href='javascript:;' yearMonth='"+currentYear+"-"+currentMonth+"' onclick='showSchList(this)'></a>");
						}
					});
					
					
				}	
			});
			
		});
		
		$("table.dataBuilder").find("span.after").live("click",function(){
			cYear=$("table.dataBuilder").find("i.year").text();
			cMonth=$("table.dataBuilder").find("i.month").text();
			
			if(cMonth==12){
				paraYear=parseInt(cYear)+1;
				paraMonth=0;
			}else{
				paraYear=cYear;
				paraMonth=cMonth;
			}
			//alert(paraYear+"--"+paraMonth);
			$.fn.showDate({
				year:paraYear,
				month:paraMonth,
				afterShowDate:function(){
					var currentYear = paraYear;
					var currentMonth = paraMonth;
					currentMonth = parseInt(currentMonth)+1;
					if(currentMonth < 10){
						currentMonth = "0"+currentMonth;
					}
					$.post("schedule!hasdays.do",{
						yearMonth:paraYear+"-"+currentMonth
					},function(data){
						var ret=$.parseJSON(data);
						$.each(ret.days,function(index,item){
							var date=item;
							date = date.substring(8);
							
							$("#mySchedule").find("td").filter(function(){
								if($(this).text()==parseInt(date,10)){
									return true;
								}
							}).wrapInner("<a href='javascript:;' yearMonth='"+currentYear+"-"+currentMonth+"' onclick='showSchList(this)'></a>").addClass("yellow");
							
							
						});
						
						if('<s:property value="#session.member.role.scheduleMang" />' == 'true'){
							$("#mySchedule").find("td").filter(function(){
								var aobj = $(this).find("a");
								if(aobj.size() < 1 && $(this).text() != null && $(this).text() != ''){
									return true;
								}
							}).wrapInner("<a href='javascript:;' yearMonth='"+currentYear+"-"+currentMonth+"' onclick='showSchList(this)'></a>");
						}
					});
					
					
				}
			});
		});
		
		$("div.select_date").find("a.insure").live("click",function(){
			paraYear=$("table.dataBuilder").find("i.year").text();
			paraMonth=$("table.dataBuilder").find("i.month").text();
			$.fn.showDate({
				afterShowDate:function(){
					var currentYear = paraYear;
					var currentMonth = paraMonth;
					currentMonth = parseInt(currentMonth);
					if(currentMonth < 10){
						currentMonth = "0"+currentMonth;
					}
					$.post("schedule!hasdays.do",{
						yearMonth:paraYear+"-"+currentMonth
					},function(data){
						var ret=$.parseJSON(data);
						$.each(ret.days,function(index,item){
							var date=item;
							date = date.substring(8);
							$("#mySchedule").find("td").filter(function(){
								if($(this).text()==parseInt(date,10)){
									return true;
								}
							}).wrapInner("<a href='javascript:;' yearMonth='"+currentYear+"-"+currentMonth+"' onclick='showSchList(this)'></a>").addClass("yellow");
						
							
						});
						
						if('<s:property value="#session.member.role.scheduleMang" />' == 'true'){
							$("#mySchedule").find("td").filter(function(){
								var aobj = $(this).find("a");
								if(aobj.size() < 1 && $(this).text() != null && $(this).text() != ''){
									return true;
								}
							}).wrapInner("<a href='javascript:;' yearMonth='"+currentYear+"-"+currentMonth+"' onclick='showSchList(this)'></a>");
						}
					});
					
					
				}
			});
		});
		
		
		
		$.defUnit.pager({
				curPage:<s:property value="scheduleList.currentPage"/>,
				totalPage:<s:property value="scheduleList.totalPage"/>,
				customStyle:"customStyle",
				containerID:"fy_container",
				afterClickPage:function(page){
					window.location.href="schedule!view.do?page="+page;
				}		
			}
		)
		
		if('<s:property value="#request.day"/>' != ''){
			$("#schedule_list").load("schedule!add.do?day=<s:property value="#request.day"/>");
		}
		
	});
	
	function showSchList(obj){
		var yearMonth = $(obj).attr('yearMonth');
		var day = $(obj).text();
		if(day < 10){
			day = "0"+day;
		}
		if('<s:property value="#session.member.role.scheduleMang"/>' == 'true'){
			$("#schedule_list").load("schedule!add.do?day="+yearMonth+"-"+day);
		}else{
			$("#schedule_list").load("schedule!schedulelist.do?day="+yearMonth+"-"+day);
		}
		
	}
	
	
</script>
</body>
</html>
